package com.czk.gateway.inclusivegateway;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

/**
 * @Author ChenZhangKun
 * @Date 2020/9/15 16:21
 */
@SuppressWarnings("all")
public class CompeletTsk {
    public static void main(String[] args) {
        // 执行任务
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        //
        TaskService taskService = processEngine.getTaskService();
        // 查询任务并完成
        Task task = taskService.createTaskQuery()
                .processDefinitionKey("inclusive")
                .taskAssignee("杨娟")
                .singleResult();
        if (task != null) {
            // 完成任务
            taskService.complete(task.getId());
            System.out.println("任务执行完毕");
        } else {
            System.out.println("没有任务");

        }
    }
}
